package com.dianzhihan.cashier.model.product;

import com.dianzhihan.cashier.controller.ErrorRedirectException;
import com.dianzhihan.cashier.model.AbsValidator;

/**
 * @author Dianzhi Han
 * @version 1.0
 * @description: 商品描述的合法性校验
 * @date 2023/2/9 12:09
 */
public class DescriptionValidator extends AbsValidator {
    @Override
    public String validate(String description, String module, String redirectUrl) {
        description =  super.validate(description, module, redirectUrl);

        if (description.length() > 200){
            throw new ErrorRedirectException("description 的长度超过 200", module, redirectUrl);
        }

        return description;
    }
}
